﻿fn main() {
    let add = |a, b| a + b; // Closure that adds two numbers
    let result = add(5, 3);
    println!("The result of the closure is: {}", result);
}



fn main() {
    let x = 10;
    let capture_by_ref = |y| y + x; // Closure captures x by reference
    println!("Captured by reference: {}", capture_by_ref(5));
    let capture_by_val = |y| y + 5; // Closure captures nothing from the environment
    println!("Captured by value: {}", capture_by_val(5));
}

